package com.example.hcbmsm.service.impl;

import com.example.hcbmsm.domain.Pre;
import com.example.hcbmsm.mapper.PreMapper;
import com.example.hcbmsm.service.PreService;
import com.example.hcbmsm.util.HCBMSMResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author Xinghm
 * @version 1.0
 * @since 2024/11/1 16:23
 */
@Service
public class PreServiceImpl implements PreService {
    @Autowired
    private PreMapper preMapper;
    @Override
    public Map add(Pre pre) {
        Long preId = preMapper.selectMaxId() + 1;
        pre.setPreId(preId);
        if (preMapper.insertSelective(pre) == 1) {
            return HCBMSMResult.SUCCESS(preId);
        }
        return HCBMSMResult.ERROR();
    }

    @Override
    public Pre getPre(Long preId) {
        return preMapper.selectByPrimaryKey(preId);
    }
}
